package karpiel.boguchwal.wojciech.przemek

import karpiel.boguchwal.wojciech.przemek.Ast._
import karpiel.boguchwal.wojciech.przemek.TokenTree.{Atom, Lst}
import org.scalatest.FunSuite

class AltAstBuilderTest extends FunSuite {

  test("yoloConvinienceMethods") {
    assert(AltAstBuilder.buildAst(
      Lst(Seq(Atom("a"), Atom("b"), Atom("c"), Atom("d")))) ==
      PiElim(PiElim(PiElim(Var("a"), Var("b")), Var("c")), Var("d"))
    )

    assert(
      AltAstBuilder.buildAst(
        Lst(Seq(Atom("Pi"), Lst(Seq(Atom("x"), Atom("A"))), Lst(Seq(Atom("y"), Atom("A"))),
          Lst(Seq(Atom("p"), Lst(Seq(Atom("Id"), Atom("x"), Atom("y"))))), Atom("Unit")))
      ) ==
        PiType(NamedType("x", Var("A")), PiType(NamedType("y", Var("A")), PiType(NamedType("p", IdType(Var("x"), Var("y"))), UnitType)))
    )

    assert(
      AltAstBuilder.buildAst(
        Lst(Seq(Atom("lambda"), Lst(Seq(Atom("x"), Atom("A"))), Lst(Seq(Atom("y"), Atom("A"))),
          Lst(Seq(Atom("p"), Lst(Seq(Atom("Id"), Atom("x"), Atom("y"))))), Atom("Unit")))
      ) ==
        PiValue(NamedType("x", Var("A")), PiValue(NamedType("y", Var("A")), PiValue(NamedType("p", IdType(Var("x"), Var("y"))), UnitType)))
    )
  }

}
